﻿using Basic.WxApiService.Interface;
using Basic.WxApiService.WxModel.Platform;
using Basic.WxLocalEvent.Interface;
using WeDonekRpc.Client.Interface;

namespace Basic.WxLocalEvent.MerBind
{
    [WeDonekRpc.Client.Attr.LocalEventName("Bind")]
    internal class SyncWxMerHandler : IEventHandler<WxMerBindEvent>
    {
        private readonly IWxPlatformService _Platform;
        private readonly IWxMerService _WxMer;

        public SyncWxMerHandler (IWxPlatformService platform,
            IWxMerService wxMer)
        {
            this._Platform = platform;
            this._WxMer = wxMer;
        }

        public void HandleEvent (WxMerBindEvent obj, string eventName)
        {
            WxMerInfo datum = this._Platform.GetMerInfo(obj.PlatformAppId, obj.WxAppId);
            this._WxMer.Add(datum);
        }

    }
}
